home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
XCMD libraries 960603
/
xcmdBase.h
< prev
next >
Wrap
Text File
|
1996-01-24
|
3KB
|
77 lines
// © Paul B. Beeken, Work In Progress, 1994-5
// Knowledge Software Consulting.
//
// These files are a mindlessly simple wrapper class for the
// basic XCMD operations. Only one instance of the xcmdBase class is
// generated per XCMD call but there may be many instances of the XCMDString
// class. I have used these classes to whip out XCMD/XFCNs within hours of
// receiving the specs. They work great for me but I will always consider
// suggestions.
//
// Please, please, please, in the unlikely event you should use this stuff
// for some commercial application I would appreciate you contacting me. If
// its for your own use, use away. Send email: knowsoft@ios.com
//
// As always: this file is presented as is with no warrantees expressed or implied.
// Swim at your own risk, etc. etc.
#pragma once
#include "xcmdStrings.h"
#ifndef __HYPERXCMD__
#include <HyperXCmd.h>
#endif
#define INVALID_INDEX 16
//
// This is the base class for all xcmds and xfcns.
// Only one of these objects is instantiated in the xcmd or xfcn code
// resource. It will setup xcmdString's static objects which handles
// the critical and very ambiguous strings required in these code resources.
//
class xcmdBase {
friend class xcmdString; // has to be our friend for us to set it up
private:
XCmdPtr paramPtr; // held static for other methods
Boolean paramsLocked;
protected:
void passMsg( Boolean p ) { paramPtr->passFlag = p; }
XCmdPtr theParamPtr( void ) { return paramPtr; }
void lockParams( void );
void unlockParams( void );
public:
xcmdBase( XCmdPtr xP, Boolean lockParams=false );
~xcmdBase( void );
/**** HyperTalk Utilities ****/
short evalExpr( xcmdString expr, xcmdString* rc ); // expression evaluation
short sendCardMessage( xcmdString msg ); // curr. card a message
short sendHCMessage( xcmdString msg ); // hypercard a message
void runScript( xcmdString handler ); // run an explicit script
/**** Memory Utilities ****/
void GetGlobal( xcmdString globName, xcmdString* globValue );
void SetGlobal( xcmdString globName, xcmdString& globValue );
void zeroBytes( Ptr dstPtr, long longCount );
/**** Set returnValue ****/
void errorMsg( xcmdString message );
void returnMsg( xcmdString message );
void returnNil( void ) { paramPtr->returnValue = nil; }
/**** Parameter checks and utilities ****/
short nParams( void ) { return paramPtr->paramCount; }
Boolean checkParameters( int min, int max=0 );
short scanParams( xcmdString str, short from=0 ); // scan all the parameters for key.
Handle operator[]( const int i );
};